package com.example.flowabledemo.controller;

import org.flowable.engine.HistoryService;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author XL
 * @version 0.1
 * @date 2021/12/11 17:47
 */
@RestController
@RequestMapping("firstmodel")
public class FirstModelController {

    @Resource
    private RuntimeService runtimeService;
    @Resource
    private TaskService taskService;
    @Resource
    private HistoryService historyService;
    @Resource
    private RepositoryService repositoryService;
    @Resource
    private ProcessEngine processEngine;

    @PostMapping("create")
    public String add(@RequestParam("initiator") String initiator,
                      @RequestParam("adminone") String adminone,
                      @RequestParam("admintwo") String admintwo) {
        HashMap<String, Object> map = new HashMap<>(4);
        // 流程参数
        map.put("initiator", initiator);
        map.put("adminone", adminone);
        map.put("admintwo", admintwo);
        //启动流程
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("M001", map);
        return "提交成功.流程Id为：" + processInstance.getId();
    }



}
